﻿/* 3. Write a program that reads from the console a sequence of N integer numbers 
 * and returns the minimal and maximal of them. */

using System;

public class MinAndMax
{
    public static void Main()
    {
        uint n;
        int number;
        int minNumber;
        int maxNumber;

        do
        {
            Console.Clear();
            Console.Write("Numbers : ");
            if ((uint.TryParse(Console.ReadLine(), out n)) && (n > 0))
                break;
        } while (true);
        
        Console.WriteLine("-------------------------");
        do
        {
            Console.Write("number 1 = ");
            if (int.TryParse(Console.ReadLine(), out number))
            {
                minNumber = number;
                maxNumber = number;
                break;
            }
        } while (true);

        for (int i = 2; i <= n; i++)
        {
            Console.Write("number {0} = ", i);
            number = int.Parse(Console.ReadLine());
            if (number < minNumber)
                minNumber = number;
            else if (maxNumber < number)
                maxNumber = number;
        }

        Console.WriteLine("-------------------------\nMinimal number = {0}\nMaximal number = {1}\n", minNumber, maxNumber);
    }
}